import json

# a = {
#     "name": "Tom",
#     "age": 25,
#     "hobbies": [ "篮球", "足球", "羽毛球"],
#     "address": {
#         "street": "123 Main St.",
#         "city": "Beijing",
#         "state": "NY",
#         "zip": "10001"
#     }
# }

# Python 对象转 JSON 字符串
# data = {
#     "name": "Alice",
#     "age": 25,
#     "hobbies": ["reading", "swimming", "cooking"]
# }
#
# json_str = json.dumps(data)
# print(json_str)
# print("--------------------")
# print(type(json_str))
# print("--------------------")

# 将 JSON 字符串转 Python 对象
# data = json.loads(json_str)
# print(data)
# print("--------------------")
# print(type(data))

# 将 Python 对象写入 JSON 文件
# with open("data.json", "w") as f:
#     json.dump(data, f)

# 将 JSON 文件中读取 Python 对象
with open('data.json', 'r', encoding='utf-8') as f:
    data = json.load(f)
print(data)